/**
 * 
 */
package entropy_analysis;

import static common.FSave.fSave;
import static common.PathJoin.pathJoin;
import static common.Print.println;
import static common.Range.range;

import java.io.File;
import java.io.IOException;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

import exactDiagonalisation.Hamiltonian;

/**
 * @author vladimir
 * 
 */
public class Exact_entropy_gen {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		println();
		int N = 3;
		double J = 1;
		double B = 3;

		int[][] neighbors = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 },
				{ -1, -1 }, { 1, 1 } };

		// int[][] neighbors = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
		Hamiltonian H = new Hamiltonian(N, J, B, neighbors);
		// double[] E = new double[40];
		// double[] T = new double[40];

		System.out.println();

		// Create a simple XY chart
		XYSeries series = new XYSeries("XYGraph");
		for (double t : range(0.5, 10.0, 0.01)) {
			// series.add(t, H.Entropy(t));
			series.add(t, H.Entropy(t));

			fSave(pathJoin("J_" + J, "B_" + B, "N" + N,
					"exact_diagonalisation", "entropy"), "T" + t, H.Entropy(t));

		}
		// Add the series to your data set
		XYSeriesCollection dataset = new XYSeriesCollection();
		dataset.addSeries(series);
		// Generate the graph
		JFreeChart chart = ChartFactory.createXYLineChart("XY Chart", // Title
				"Temperature", // x-axis Label
				"Entropy", // y-axis Label
				dataset, // Dataset
				PlotOrientation.VERTICAL, // Plot Orientation
				true, // Show Legend
				true, // Use tooltips
				false // Configure chart to generate URLs?
				);
		try {
			ChartUtilities.saveChartAsJPEG(new File("entropy.jpg"), chart,
					1400, 900);
		} catch (IOException e) {
			System.err.println("Problem occurred creating chart.");
		}
	}
}
